package com.dianban.config.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author wujh
 * @version 2020/6/28
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.dianban.controller"))
                .paths(PathSelectors.any())
                .build().apiInfo(new ApiInfoBuilder()
                        .title("荣耀兔支付相关接口")
                        .description("荣耀兔支付相关接口，详细信息......")
                        .version("1.0.0")
                       // .contact(new Contact("啊啊啊啊","blog.csdn.net","aaa@gmail.com"))
                    //    .license("The Apache License")
                     //   .licenseUrl("http://www.baidu.com")
                        .build());
    }

    private ApiInfo apiInfo(String name, String description, String version) {
        return new ApiInfoBuilder().title(name).description(description).version(version).build();
    }

    @Bean
    public Docket nengliangRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo("能量舱微信小程序接口文档", "能量舱微信小程序接口文档", "1.0.0"))
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.ant("/api/nengliang/**/**"))
                .build()
                .groupName("能量舱微信小程序接口文档V1.0.0")
                .pathMapping("/");
    }
}
